<!DOCTYPE html>
<html lang="zh-CN">
{% block xxxx %} {% endblock %}


{% block head %}

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/admin.css') }}">
    <!-- <link rel="stylesheet" href="../css/admin.css"> -->
    {% block style %} {% endblock %}
    {% block head_js %} {% endblock %}
    <title>Admin|{% block title %} {% endblock %}</title>
</head>
{% endblock %}

{% block body %}

<body>
    <div class="msg-box">
        {% for category,message in get_flashed_messages(with_categories=True) %}
            <div class="msg  {{ category }}">
                <div class="text">{{ message }}</div>
            </div>
        {% endfor %}
        <script>
            let box = document.querySelector(".msg-box")
            box.addEventListener("animationend", function(){
                box.remove()
            })
        </script>
    </div>
    {% block main %}
    <main>
        <div class="top-info">
            <div class="logo">
                <a href="/">
                    {{site_config.get('name')}}
                </a>
            </div>
            <div class="info">
                <a href="{{ url_for('views.admin_logout') }}">退出</a>
                后台管理页
            </div>
        </div>
        <div class="left-nav">
            <ul>
                <li class="active"><a href="{{ url_for('views.admin') }}">站点管理</a></li>
                <li><a href="{{ url_for('views.admin_links') }}">友链管理</a></li>
                <li><a href="{{ url_for('views.admin_article') }}">文章管理</a></li>
                <li><a href="{{ url_for('views.admin_info') }}">信息管理</a></li>
            </ul>
        </div>
        <div class="content">
            {% block main_content %}{% endblock %}
        </div>
    </main>
    {% endblock %}
    <script>
        let href = window.location.origin + window.location.pathname
        let lis = document.querySelectorAll('.left-nav ul li')
        lis.forEach(function(v,i){
            v.className = ""
        })
        let f = false
        for (let i = 0; i < lis.length; i++) {
            if (href == lis[i].querySelector('a').href) {
                lis[i].className = 'active'
                f = true
            }
        }
        if (!f){
            lis[0].className = 'active'
        }
    </script>
    {% block js %}
    {% endblock %}
</body>
{% endblock %}



</html>